package van.planifolia.strategy;

/**
 * Created by Intellij IDEA<br>
 * 客户端类
 *
 * @author Planifolia.Van
 * @version 1.0
 * @date 2022/11/10 17:34
 */
public class JDClick {
    /**
     * 引入折扣策略对象
     */
    private Discount discount;

    /**
     * 设置打折的策略
     *
     * @param discount 打折的策略对象
     */
    public void setDiscount(Discount discount) {
        this.discount = discount;
    }

    /**
     * 购买的方法
     *
     * @param price 购买的金额
     */
    public void buy(double price) {
        if (discount == null){
            System.out.println("无促销策略，应收金额 : " + price);
        }else {
            System.out.println("打完折后应收金额 : " + discount.productPromotion(price));
        }
    }
}
